#pragma once

/**
Singleton implementation. Requiers you to define the static singleton variable in the target source file,
as well as the target class to have a default constructor
**/
template<typename T>
class Singleton{
public:
	static T	&instance(){
		if(!singleton)
			singleton=new T;
		return *singleton;
	}
	static T	*instanceptr(){
		if(!singleton)
			singleton=new T;
		return singleton;
	}
	static void freeinstance(){
		if(singleton){
			delete singleton;
			singleton=0;
		}
	}
private:
	static T	*singleton;
};